import Layout from '@/core/page/index'
import module from '../module'
const pageViews = []
const requireComponent = require.context('../views', true, /i\.js$/)
requireComponent.keys().map(fileName => {
    const nameList = fileName.split('/')
    if (nameList.length == 3 && nameList[2] == 'i.js') {
        const name = nameList[1]
        pageViews.push({ name: '', path: `/${module.code}/${name}`, meta: requireComponent(fileName).default })
    }
})
pageViews.push(
    {
      name: "预览",
      path: `/${module.code}/3dDisplay/preview3D`,
      meta: {
        name: "预览",
        isNotMenu: true,
        isTab: false,
      },
      isNotMenu: true,
    },
  );
  export default pageViews.map((t) => {
    const componentName = t.path.replace(`/${module.code}`, "");
    if (t.isNotMenu) {
      return {
        path: t.path,
        name: t.name,
        meta: t.meta,
        props: true,
        component: () =>
          import(
            /* webpackChunkName: "[request]" */ `../views${componentName}`
          ),
      };
    } else {
      return {
        path: t.path,
        component: Layout,
        redirect: `${t.path}/index`,
        children: [
          {
            path: "index",
            name: t.name,
            meta: t.meta,
            component:async() => {
              let cpn = await import(/* webpackChunkName: "[request]" */ `../views${componentName}/index`);
              cpn.default.name = `page${t.path.replace(/\//g,'-')}-index`;
              return cpn;
            }
          },
        ],
      };
    }
  });
